package shixun.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import shixun.dao.accountInfDao;
import shixun.domain.accountInf;
import shixun.domain.User;
import shixun.service.accountInfService;

import java.util.List;

@Service
public class AccountInfServiceImpl implements accountInfService {
    @Autowired
    private accountInfDao savingsDepositCardInfDao;

    public double getCurrentMoney(int id,int type) {
        List<Double> currentMoney = savingsDepositCardInfDao.getCurrentMoney(id,type);
        int currentId = currentMoney.size() - 1;
        if(currentId<0){
            return -0.001;
        }
        return currentMoney.get(currentId);
    }


    public void insertInformation(String information, int id, double AllMoney,int type) {
        savingsDepositCardInfDao.insertInformation(information, id, AllMoney,type);
    }

    public List<accountInf> findInformationById(int id,int type) {
        List<accountInf> savingsdepositcardinfList = savingsDepositCardInfDao.findInformationById(id,type);
        return savingsdepositcardinfList;
    }

    @Override
    public List<User> findOtherById(int id) {
        List<User> userList = savingsDepositCardInfDao.findOtherById(id);
        return userList;
    }

    public int findNumber(int id,int type){
        int number = savingsDepositCardInfDao.findNumber(id,type);
        return number;
    }



}
